const btn = document.querySelector('#btnLogin')
const usernameInput = document.querySelector('#username')
const passwordInput = document.querySelector('#password')
btn.addEventListener('click', async function () {
  const username = usernameInput.value
  const password = passwordInput.value
  try {
    const { data: res } = await axios({
      url: 'http://ajax-api.itheima.net/api/login',
      method: 'POST',
      data: {
        username,
        password,
      },
    })
    alert(res.message + '嘿嘿嘿' + res.data.account)
    console.log(res)
  } catch (error) {
    console.log(error)
    alert('登陆失败')
  }
})
